<!DOCTYPE html>
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="css/UngradedTestList.css">
		
			
		<link rel="stylesheet" type="text/css" href="css/smoothness/jquery-ui-1.10.0.custom.css" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<script type="text/javascript" src="JQuery/jquery-1.9.0.min.js"></script>
		<script type="text/javascript" src="JS/UngradedTestList.js"></script>
		<script type="text/javascript" src="JQuery/jquery-ui-1.10.0.custom.js"></script>	
	
		
		<title>Page Title</title>
	</head>
	<body>
		<div id="UngradedListMain">
		<?php
		require('webservices.php');
		
		require_once('session_handler.php');
        session_handler_start();
		
		echo '<div id="ULTab"><ul>';
        
        $Classes = Get_class_info($_SESSION['userid']);
        
        foreach($Classes as $Index=>$Class)
        {
            echo  '<li><a href="#' . $Index . '" >' . $Class['CombinedName'] . '</a></li>';
        
        }
        
		echo '</ul>';
		
		foreach($Classes as $Index=>$Class)
		{
			echo  '<div id="' . $Index . '" class="GradeTab" >';
			$TestRecords = Get_ungraded_test($Class['course_id']);
			
			if(!empty($TestRecords))
			{
			
				echo '<div class="TestAccordion">';
				
				$CurrentTestName = $TestRecords[0]['TestName'];
				
				
				echo '<h3>' . $TestRecords[0]['TestName'] . '</h3>';
				echo '<div>';
				echo '<table id="TestListTable">';
				echo '<thead>';
				echo '<tr>';
					echo '<th>Student</th>';
					echo '<th>Date</th>';					
				echo '</tr>';
				echo '</thead>';	
				echo '<tbody>';
				foreach($TestRecords as $Index => $TestRecord)
				{
					if($TestRecord['TestName'] != $CurrentTestName)
					{
						echo '</tbody>';
						echo '</table>';
						echo '</div>';
						
						echo '<h3>' . $TestRecord['TestName'] . '</h3>';
						echo '<div>';
						echo '<table id="TestListTable">';
						echo '<thead>';
						echo '<tr>';
							echo '<th>Student</th>';
							echo '<th>Date</th>';					
						echo '</tr>';
						echo '</thead>';	
						echo '<tbody>';
					}
					
					echo '<tr id="' . $TestRecord['id']  . '" class="GradeRow">';
						echo '<td class="FullName">' . $TestRecord['FullName'] . '</td>';
						echo '<td class="TakenDate">' . $TestRecord['TakenDate'] . '</td>';
					
					echo '</tr>';
				}
				
				echo '</tbody>';
				echo '</table>';
				echo '</div>';
				echo '</div>';
			}
			else
			{
				echo '<span class="NoTest">No new test to be graded</span>';
			}
			
			echo '</div>';
			
		}

		echo '</div>';
		?>
		</div>
	</body>
			
</html>
